package com.tom.service.impl;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;

import com.tom.util.HttpRequest;
import com.tom.util.JDBCUtil;

public class CheEDai {

	/**
	 * 
	 * @author hanpengda
	 * @date 2018年5月10日
	 * @TODO 获取车E贷url
	 */
	public static void work(){
		try {
			ArrayList<String> arrayList = JDBCUtil.getUrls("qss_ced_url");
			ArrayList<String> list = new ArrayList<String>();
			for (int i = 0; i < arrayList.size(); i++) {
				String url = arrayList.get(i);
				String [] links = url.split("###");
				//System.out.println(links.length);
				for(int j = 0; j < links.length; j++){
					String link = links[j];
					if (link.indexOf("还款中") != -1) {
						link = link.replaceAll("<a href=", "").replaceAll(" class=\"gm_icon ytm_icon\">还款中</a>", "").replaceAll("\"", "");
						url = "https://www.cedp2p.com"+link;
						Date now = new Date(); 
						SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
						String time = dateFormat.format(now);
						String sql = "insert into qss_ced_link(url,insertdate)values("+"'"+url+"'"+","+"'"+time+"'"+")";
						System.out.println(sql);
						list.add(sql);
					}
				}
			}
			//添加数据库操作
			//JDBCUtil.insertData(list);
		} catch (Exception e) {
			// TODO: handle exception
		}
	}
}
